import request from '@/utils/request.js'
const PATH = '/admin/user'

// 新增用户
export const insertUser = (data) => {
  console.log(data)

  return request.post(PATH + '/insert', data)
}

// 分页查询用户
export const getUserList = ({ page, pageSize, name, phone, status }) => {
  return request.get(PATH + '/pageQuery', {
    params: {
      page,
      pageSize,
      name,
      phone,
      status
    }
  })
}

// 修改用户状态
export const updateUserStatus = ({ id, status }) => {
  return request.post(PATH + `/status/${status}`, {
    id
  })
}

// 批量删除用户
export const batchDeleteUser = (ids) => {
  return request.delete(PATH + '/batchDelete', {
    params: {
      ids: ids.join(',') // 将 ids 数组转换为逗号分隔的字符串
    }
  })
}

// 根据id查询用户
export const getUserById = (id) => {
  return request.get(PATH + '/getUserById', {
    params: {
      id
    }
  })
}

// 修改用户信息
export const updateUser = (data) => {
  return request.put(PATH + '/update', data)
}
